package forms;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import db.DbConnectionPool;
import db.DbException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class formRegist extends ActionForm {
	private static final long serialVersionUID = 1L;
	private String loginName = null;
	private String pw1 = null;
	private String pw2 = null;
	private String email = null;
	public String getLoginName()
	{
		return loginName;
	}
	public String getPw1()
	{
		return pw1;
	}
	public String getPw2()
	{
		return pw2;
	}
	public String getEmail()
	{
		return email;
	}
	public void setLoginName(String loginName)
	{
		this.loginName = loginName;
	}
	public void setPw1(String pw1)
	{
		this.pw1 = pw1;
	}
	public void setPw2(String pw2)
	{
		this.pw2 = pw2;
	}
	public void setEmail(String email)
	{
		this.email = email;
	}
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		setLoginName(null);
		setPw1(null);
		setPw2(null);
		setEmail(null);
	}
	
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		if(loginName == null || loginName.length() < 1)
			errors.add("firstMsgTag1", new ActionMessage("error.username.required"));
		if(pw1 == null || pw2 == null|| pw1.length() < 1 || pw2.length() < 1)
			errors.add("secondMsgTag2",new ActionMessage("error.password.required"));
		if(pw1 != null && pw2 != null)
		if(!(pw1.equals(pw2)))
				errors.add("thirdMsgTag2", new ActionMessage("error.password.notMatch"));
		return errors;
	}
	
}
